package gruppoSoluzione.mainService.services;

/**
 * Enumerazione che descrive tutti i mime http
 * 
 * @author Alessandro Martinelli
 */
public enum MimeHTTP {
	HTML("text/html"),
	CSS("text/css"),
	JAVASCRIPT("text/javascript"),
	XML("text/xml"),
	JPEG("image/jpeg"),
	PNG("image/png"),
	ZIP("application/zip"),
	TXT("text/plain");
	//Note: basterebbe recuperare l'elenco completo di tutti i MIME standard per fare una enumerazione completa ed esaustiva
	private String value;

	private MimeHTTP(String value) {
		this.value = value;
	}
	
	public String getValue() {
		return value;
	}
	
	public static MimeHTTP getMimeByFilename(String filename){
		if(filename.endsWith("css")){
			return CSS;
		}else if (filename.endsWith("js")){
			return JAVASCRIPT;
		}else if (filename.endsWith("xml")){
			return XML;
		}else if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".JPG") || filename.endsWith(".JPEG")) {
			return JPEG;
		}else if (filename.endsWith(".png") || filename.endsWith(".PNG")) {
			return PNG;
		}else if (filename.endsWith(".zip")) {
			return ZIP;
		}else if (filename.endsWith(".txt") || filename.endsWith(".TXT")) {
			return TXT;
		}
		return HTML;
	}
}
